﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MallProject.Admin.Controller;
using MallProject.Model;

namespace MallProject.Admin.View.Setting
{
    public partial class Index : System.Web.UI.Page
    {
        SettingController settingController = new SettingController();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtCompany.Text = SettingController.getValue("Company").ToString();
                txtAddress.Text = SettingController.getValue("Address").ToString();
                txtEmail.Text = SettingController.getValue("Email").ToString();
                txtFax.Text = SettingController.getValue("Fax").ToString();
                txtPhone.Text = SettingController.getValue("Phone").ToString();
                Description.Text = SettingController.getValue("Description").ToString();
                Keyword.Text = SettingController.getValue("Keyword").ToString();
            }
        }

        protected void Save_Click(object sender, EventArgs e)
        {

            string Company = txtCompany.Text;
            string ade = txtAddress.Text;
            string Email = txtEmail.Text;
            string Fax = txtFax.Text;
            string Phone = txtPhone.Text;
            string Descriptions = Description.Text;
            string Keywords = Keyword.Text;
            List<Settings> LSetting = new List<Settings>();
            Settings sCompany = SettingController.getValue("Company");
            sCompany.Value = Company;
            LSetting.Add(sCompany);
            Settings sAddress = SettingController.getValue("Address");
            sAddress.Value = ade;
            LSetting.Add(sAddress);
            Settings sEmail = SettingController.getValue("Email");
            sEmail.Value = Email;
            LSetting.Add(sEmail);
            Settings sFax = SettingController.getValue("Fax");
            sFax.Value = Fax;
            LSetting.Add(sFax);
            Settings sPhone = SettingController.getValue("Phone");
            sPhone.Value = Phone;
            LSetting.Add(sPhone);
            Settings sDescription = SettingController.getValue("Description");
            sDescription.Value = Descriptions;
            LSetting.Add(sDescription);
            Settings sKeyword = SettingController.getValue("Keyword");
            sKeyword.Value = Keywords;
            LSetting.Add(sKeyword);
            settingController.UpdateMulti(LSetting);
        }
    }
}